﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MotionControl;
using System.Diagnostics;
using System.Threading;

namespace MainFrame
{
    public partial class FormAlarm : Form
    {
        //CardMotion cardm;
        //public delegate void laminateDelegate(int m);
        //laminateDelegate laminateDel;
        //bool totalError = false;
        public FormAlarm()
        {
            InitializeComponent();
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {           
            this.Close();
            clearInfo();
            //GlobalMotion.Card_1.setOut((ushort)e_light_IOport.yellow, e_out_OnOff.off);//取消黄灯报警
        }

        private void updateDisplay()
        {
            for (int i = 0; i < GlobalVar.errorTips.Length; i++)
            {
                if (!GlobalVar.warningTips[i].haveInfo)
                    GlobalVar.warningTips[i].Info = string.Empty;
                switch (i)
                {
                    case (int)e_warningType.motor:
                        Invoke(new Action(() => lbl_motor.Text = GlobalVar.warningTips[i].Info));
                        break;
                    case (int)e_warningType.removeMaterail:
                        Invoke(new Action(() => lbl_need_remove_material.Text = GlobalVar.warningTips[i].Info));
                        break;
                    case (int)e_warningType.addMaterial:
                        Invoke(new Action(() => lbl_need_addMaterail.Text = GlobalVar.warningTips[i].Info));
                        break;
                    case (int)e_warningType.sucker:
                        Invoke(new Action(() => lbl_sucker.Text = GlobalVar.warningTips[i].Info));
                        break;
                    case (int)e_warningType.isFlip:
                        Invoke(new Action(() => lbl_isFlip.Text = GlobalVar.warningTips[i].Info));
                        break;
                }
            }
    
         
        }
        private void clearInfo()
        {
            //totalError = false;
            GlobalVar.warningTips[(int)e_warningType.motor].haveInfo = false;
            GlobalVar.warningTips[(int)e_warningType.motor].Info = "";
            GlobalVar.warningTips[(int)e_warningType.removeMaterail].haveInfo = false;
            GlobalVar.warningTips[(int)e_warningType.addMaterial].haveInfo = false;
            GlobalVar.warningTips[(int)e_warningType.sucker].haveInfo = false;
            GlobalVar.warningTips[(int)e_warningType.sucker].Info = "";

            GlobalVar.warningTips[(int)e_warningType.isFlip].haveInfo = false;
            GlobalVar.warningTips[(int)e_warningType.isFlip].Info = "";

            lbl_CompletePlan.Text = "";
            lbl_need_addMaterail.Text = "";
            lbl_need_remove_material.Text = "";
            lbl_sucker.Text = "";
            lbl_motor.Text = "";
            lbl_isFlip.Text = "";
        }

        private void FormAlarm_Load(object sender, EventArgs e)
        {

            GlobalVar.isAutoRun = false;//自动运行停止 
            GlobalVar.isPause = true;
            updateDisplay();
        }

        private void FormAlarm_FormClosed(object sender, FormClosedEventArgs e)
        {
          
        }

   
    }
}
